import scrapy


class Geektime3spiderSpider(scrapy.Spider):
    name = "geektime3Spider"
    allowed_domains = ["quotes.toscrape.com"]
    start_urls = ["https://quotes.toscrape.com"]

    def parse(self, response):
        for quote in response.css('div.quote'):
            yield {
            'text': quote.css('span.text::text').get(),
            'author': quote.css('small.author::text').get(),
            'tags': quote.css('div.tags a.tag::text').getall(),
            }
            # ========================================================================
  #          next_page = response.css('li.next a::attr(href)').get()

  #          if next_page is not None:
  #          # 直接使⽤ response.follow 即可
  #              yield response.follow(next_page, callback=self.parse)

  #          # 当需要获取 a 标签的 href 属性时，⽀持⾃动获取
  #          # ========================================================================
  #          for a in response.css('ul.pager a'):
  #              yield response.follow(a, callback=self.parse)

            # 进⼀步缩短, 使⽤ follow_all ⽅法
            # ========================================================================
        yield from response.follow_all(css='ul.pager a', callback=self.parse)
